<?php
namespace Admin\Controller;
class LogController extends EmptyController {
	
  //显示登录页面 
  public function  index(){
	  
	  $this->display();
 
  }
  
  //显示验证码
  public function verify(){
	 
    $config=array(
	  'fontSize'=>18,//验证码字体大小
	  'length'=>4,//验证码位数
	  'useNoise'=>false,//关闭验证码杂点
	  'useCurve'=>false,
	  'imageW'=>120,
	  'imageH'=>40,
	  'bg'=>array(160,180,230)
	 );	 
	$Verify=new \Think\Verify($config);
	ob_clean();
	$Verify->entry();
  }
  
  /*
  *
  *
  *登录验证
  */
  public function handle_login(){
	  
	  $aname=I('post.a_name','');
	  
	  $apwd=I('post.a_pwd','');
	  
	  $verify=I('post.verify','');
	  
	  !is_empty($aname,$apwd,$verify)?message(2,L('_IS_EMPTY_')):'';
	  
	  $obj_verify = new \Think\Verify();

	  $obj_verify->check($verify)?'':message(2,L('_NO_VERIFY_'));
      
	  $admin_arr=M('admin')->where(array('aname'=>$aname,'apwd'=>md5($apwd.C('SALT'))))->find();
      
	  if(!empty($admin_arr)){
		  
		  $_SESSION['admin_info']=$admin_arr;
		  
		  $logo_arr=M('website')->field('wlogo')->where(array('ename'=>$_SESSION['admin_info']['ename']))->find();
		  
		  $_SESSION['admin_info']['logo']=$logo_arr['wlogo'];
		  
		  message(1,L('_LOGIN_SUCCEED_'),U('Admin/index'));
	  }
	 
	  message(2,L('_FALSE_USR_PWD_'));
	 
  }
  
   /*
   *
   *退出登录
   *
   */   
   public function quit(){
	   
	   unset($_SESSION['admin_info']);
	   
	   session_destroy();
	   
	   header('Location:'.U('Log/index'));
	   
   }
   
   
}

 